/* Extensions to Glib 2 */

#ifndef __KEW_GLIBEXT_H__
#define __KEW_GLIBEXT_H__

#include <glib/glib.h>

G_BEGIN_DECLS

#define g_ptr_array_contains_index(array,index) ((index) >= 0 && (index) < g_ptr_array_size(array))

/* g_list_append but g_ptr_array_add (sigh), add prob makes more sense (applies to all collections) */
/* g_list_length is prob not as good as g_ptr_array_size (size applies to all collections) */
#define g_ptr_array_size(array) ((array)->len)

/* setter and getter are more independent of implementation than indexing tricks */
#define g_ptr_array_get_index(array,index) g_ptr_array_index(array,index)
#define g_ptr_array_set_index(array,index,value) g_ptr_array_index(array,index) = value;

GPtrArray *g_ptr_array_copy_from_array(gpointer *array, guint size);
GPtrArray *g_ptr_array_copy(GPtrArray *original);
GPtrArray *g_ptr_array_copy_add(GPtrArray *original, gpointer value);
GPtrArray *g_ptr_array_copy_add_first(GPtrArray *original, gpointer value);
GPtrArray *g_ptr_array_concat(GPtrArray *original1, GPtrArray *original2);

G_END_DECLS

#endif
